package com.ftl;


//import freemarker.template.Configuration;

import freemarker.template.Configuration;
import freemarker.template.Template;

import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
${name}你好，${message}哈哈${data}
public class ftl {
public static void main(String[] args)throws Exception {
//1.创建配置类
//1.创建配置类
Configuration configuration=new Configuration(Configuration.getVersion());
//2.设置模板所在的目录
configuration.setDirectoryForTemplateLoading(new File("G:\\dev\\IdeaProjects\\my_health\\MyExan\\src\\main\\java\\com\\ftl\\"));
//3.设置字符集
configuration.setDefaultEncoding("utf-8");
//4.加载模板
Template template = configuration.getTemplate("demo.ftl");
//5.创建数据模型
Map map=new HashMap();
map.put("name", "张三");
map.put("message", "欢迎来到传智播客！");
map.put("data","我是我是我是");
//6.创建Writer对象
Writer out =new FileWriter(new File("d:\\test.java"));
//7.输出
template.process(map, out);
//8.关闭Writer对象
out.close();
}
}
